<?php

//获取产品分类名称
function get_product_cat_name($catid=0){
	global $db;
	$sql = "select * from ".PCAT." where catid='$catid' ";
	$db->query($sql);
	$cat_name = $db->fetchField('cat');
	return !empty($cat_name) ? $cat_name : '暂无';
}
//获取场馆名称
function get_spot_name($spot_id){
	global $db;
	$sql = "select * from ".SPOT." where id='$spot_id' ";
	$db->query($sql);
	$spot_name = $db->fetchField('spot_name');
	return !empty($spot_name) ? $spot_name : '未知';

}
//获取场馆地址
function get_spot_address($spot_id){
	global $db;
	$sql = "select * from ".SPOT." where id='$spot_id' ";
	$db->query($sql);
	$address = $db->fetchField('address');
	return !empty($address) ? $address : '未知';
}
//获取场馆分类名称
function get_spot_model_name($id){
	global $db;
	$sql = "select * from ".SPOTMODEL." where id = '$id'  ";
	$db->query($sql);
	$model_name = $db->fetchField('model_name');
	return !empty($model_name) ? $model_name : '未知';

}

//发送短信
function jh_send_sms($mobile,$content,$temp=1){
	$productid['1'] = '676767';
	$productid['2'] = '887362';
	$content=urlencode($content);
	$content = iconv("gb2312//IGNORE","utf-8",$content);
	$url = "http://www.ztsms.cn/sendXSms.do?username=hxpw&password=".md5("Haixia123")."&mobile=".$mobile."&content=".
			$content."&productid=".$productid[$temp]."&dstime=&xh=";
	$result = file_get_contents($url);
//	$ch = curl_init();
//	curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
//	curl_setopt($ch, CURLOPT_URL, $url);
//	$result =  curl_exec($ch);
//	curl_close($ch);
	return $result;
}

function get_pay_config($type)
{
	global $db,$config;
	$sql="select * from ".PAYMENT." where payment_type='$type'";
	$db->query($sql);
	$re=$db->fetchRow();
	$re=unserialize($re['payment_config']);
	foreach($re as $v)
	{
		$name=$v['name'];
		$cn[$name]=$v['value'];
	}
	if($type=='alipay')
	{
		$url=$config['weburl']."/main.php?m=payment&s=admin_accounts_base&onlinepaytype=alipay";
		$cn['sign_type']    = 'MD5';
		$cn['input_charset']= 'utf-8';
		$cn['transport']    = 'http';
		$cn['return_url']   = $url;
		$cn['notify_url']   = $url;
	}
	if($type == 'wapalipay'){
		$url=$config['weburl']."/main.php?m=payment&s=admin_accounts_base&onlinepaytype=wapalipay";
		$cn['seller_id']   = $cn['partner'];
		$cn['return_url']   = $url;
		$cn['notify_url']   = $url;
		$cn['sign_type']    = strtoupper('RSA');
		$cn['input_charset']= strtolower('utf-8');
		$cn['cacert']    = getcwd().'/../lib/wapalipay/cacert.pem';
		$cn['transport']    = 'http';
		$cn['payment_type']   = 1;
		$cn['service']   = "alipay.wap.create.direct.pay.by.user";
	}

	return $cn;
}




?>